from Uniut1.Base import Base
from selenium.webdriver.common.by import By
class Page(Base):
    # 定位
    # 请登录
    q_login_loc=(By.LINK_TEXT,"请登录")
    # 输入用户名id="userName"
    userName_loc=(By.ID,"userName")
    # 输入密码name="_pwd"
    password_loc=(By.NAME,"_pwd")
    # 点击登录name="bi_Usuallogin"
    bi_Usuallogin_loc=(By.NAME,"bi_Usuallogin")
    # 点击确定class="bindSub"
    bindSub_loc=(By.CLASS_NAME,"bindSub")
    # 点击疯狂抢购//*[@id="crazySale"]/div[1]/div[1]/ul/li[1]
    n1_on_loc=(By.XPATH,'//*[@id="crazySale"]/div[1]/div[1]/ul/li[1]')
    # 选择商品href="https://www.jiuxian.com/goods-1975145.html?src=4767&source=52"
    goos_loc=(By.XPATH,'//a[@href="https://www.jiuxian.com/goods-1975145.html?src=4767&source=52"]')
    # 点击添加购物车a  name="detail_jiarugouwuche"  id="addToCartForDetail"
    detail_loc=(By.XPATH,'//a[@name="detail_jiarugouwuche" and @id="addToCartForDetail"]')
    # 点击查看购物车//*[@id="u-buy-layId"]/div/div[3]/a[2]
    buy_loc=(By.XPATH,'//*[@id="u-buy-layId"]/div/div[3]/a[2]')
    # 点击却结算class="done"
    done_loc=(By.CSS_SELECTOR,'.done')
    # 下滑800
    # 提交订单class ="submitBtn"
    submitBtn_loc=(By.CLASS_NAME,"submitBtn")




    # 封装
    # 请登录
    def q_login(self):
        self.click(self.q_login_loc)

    # 输入用户名id="userName"
    # 调用yaml里面的username文件
    def userName(self,username):
        self.send_keys(self.userName_loc,username)

    # 输入密码name="_pwd"
    # 调用yaml里面的password文件
    def password(self,password):
        self.send_keys(self.password_loc,password)

    # 点击登录name="bi_Usuallogin"
    def bi_Usuallogin(self):
        self.click(self.bi_Usuallogin_loc)

    # 点击确定class="bindSub"
    def bindSub(self):
        self.click(self.bindSub_loc)

    # 点击疯狂抢购
    def n1_on(self):
        self.click(self.n1_on_loc)

    # 选择商品href="https://www.jiuxian.com/goods-1975145.html?src=4767&source=52"
    def goos(self):
        self.click(self.goos_loc)
    # 切换页面
    def qiehuan1(self):
        self.qiehuan()
    # 点击添加购物车a  name="detail_jiarugouwuche"  id="addToCartForDetail"
    def detail(self):
        self.click(self.detail_loc)

    # 点击查看购物车//*[@id="u-buy-layId"]/div/div[3]/a[2]
    def buy(self):
        self.click(self.buy_loc)

    # 点击却结算class="done"
    def done(self):
        self.click(self.done_loc)
    # 滚动条0，800
    def gun(self):
        self.gundong(800)
    # 提交订单class ="submitBtn"
    def submitBtn(self):
        self.click(self.submitBtn_loc)























    # 业务逻辑
    def test_01_liuji(self):
        self.open_url("https://www.jiuxian.com/")